﻿// ===============================================================================
//  Copyright © ymind.net. All rights reserved .
//  官方网站：http://ymind.net/
//  版权所有：彦铭工作室 老陈出品
// ===============================================================================

using System;
using System.Collections.Generic;

namespace Lcsoft.RssEngine.Collections
{
	/// <summary>A strongly typed collection of <see cref="Exception"/> objects</summary>
	[Serializable]
	public class ExceptionCollection : List<Exception>
	{
		/// <summary>Returns the last exception added through the Add method.</summary>
		/// <value>The last exception -or- null if no exceptions exist</value>
		public Exception LastException { get; private set; }

		/// <summary>Adds a specified exception to this collection.</summary>
		/// <param name="exception">The exception to add.</param>
		/// <returns>The zero-based index of the added exception -or- -1 if the exception already exists.</returns>
		public new void Add(Exception exception)
		{
			if (this.Contains(exception)) return;

			this.LastException = exception;

			base.Add(exception);
		}
	}
}
